import com.alibaba.fastjson2.JSON;
import org.zjx.cache.FileCache;
import org.zjx.entity.CacheBean;

import java.util.ArrayList;
import java.util.List;

public class CacheFile {

    public static void main(String[] args) throws Exception {
        List<CacheBean> cacheBeans = new ArrayList<CacheBean>();
        cacheBeans.add(new CacheBean("姓名","张三"));
        cacheBeans.add(new CacheBean("姓名","李四"));
        cacheBeans.add(new CacheBean("职业","开发"));
        cacheBeans.add(new CacheBean("职业","教师"));

        FileCache fileCache = new FileCache("CacheFile.txt");

        fileCache.put("缓存", JSON.toJSONString(cacheBeans));

        String cb = fileCache.get("缓存");
        List<CacheBean> cacheBeans1 = JSON.parseArray(cb, CacheBean.class);
        for (CacheBean cacheBean : cacheBeans1) {
            System.out.println(cacheBean);
        }
    }
}
